import request from "@/service/request";
import requestAly from "@/service/requestAly";

// 获取凭证
const getOssAuth = (query: any) => {
  return request({
    url: "/system/oss/uploadAuth",
    method: "get",
    params: query,
  });
};

// 文件上传到OSS
const postToOSS = (File: any) => {
  return requestAly({
    url: ``,
    method: "post",
    data: File,
  });
};

// 新增文章
const addArtic = (query: any) => {
  return request({
    url: `/school/article`,
    method: "post",
    data: query,
  });
};

// 获取文章列表
const getArticList = (query: any) => {
  return request({
    url: `/school/article/list`,
    method: "get",
    params: query,
  });
};

// 获取文章详情
const articDetail = (id: any) => {
  return request({
    url: `/school/article/` + id,
    method: "get",
  });
};

// 修改文章内容
const editArtic = (query: any) => {
  return request({
    url: `/school/article/edit`,
    method: "put",
    data: query,
  });
};

// 删除文章
const delArtic = (id: string | string[]) => {
  return request({
    url: `/school/article/`+ id,
    method: "delete",
  });
}

export {
  getOssAuth,
  postToOSS,
  addArtic,
  getArticList,
  articDetail,
  editArtic,
  delArtic
};
